]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
quickSettings: Add insertItemBefore() method
authorFlorian Müllner <fmuellner@gnome.org>
Mon, 14 Aug 2023 22:13:34 +0000 (00:13 +0200)
committerFlorian Müllner <fmuellner@gnome.org>
Sat, 19 Aug 2023 23:54:09 +0000 (01:54 +0200)
The QuickSettings menu currently only support appending items
at the end. Extensions can get around that limitation by accessing
the private grid property to move the item afterwards, but we don't
allow this in our own code.

Expose a new insertItemBefore() method that allows adding an item
before an existing one.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2894>

js/ui/quickSettings.js

index 83597c6d454f6c45ac1e956eeb9f61462ac252aa..c684141f757b7003ada7804c72cfbf241cf2fe48 100644 (file)
@@ -780,6 +780,15 @@ export const QuickSettingsMenu = class extends PopupMenu.PopupMenu {
 
     addItem(item, colSpan = 1) {
         this._grid.add_child(item);
+        this._completeAddItem(item, colSpan);
+    }
+
+    insertItemBefore(item, sibling, colSpan = 1) {
+        this._grid.insert_child_below(item, sibling);
+        this._completeAddItem(item, colSpan);
+    }
+
+    _completeAddItem(item, colSpan) {
         this._grid.layout_manager.child_set_property(
             this._grid, item, 'column-span', colSpan);